<template>
    <div class="app-container">
      <el-card class="box-card">
        <div slot="header" class="clearfix">
          <span>编辑$TABLENAME$</span>
        </div>
  
        <el-form ref="form" :model="form"  label-width="120px">
            $--FORMITEM--$

          <el-form-item>
            <el-button type="primary" @click="submitForm">保存修改</el-button>
            <el-button @click="goBack">返回</el-button>
          </el-form-item>
        </el-form>
      </el-card>
  
    </div>
  </template>
  
  <script>
  import { getObj, updateObj } from '@/api/$TABLENAME$'
  
  export default {
    name: 'Edit$TABLENAME$',
    data() {
      return {
        domain: 'http://localhost:3000',
        form: {
          $--FORMATTRIBUTE--$
        },



      }
    },
    computed: {

    },
    created() {
      this.getDetail()
    },
    methods: {

      async getDetail() {
        try {
          const { data } = await getObj(this.$route.params.id)
          // 处理返回的数据
          this.form = {
            ...data,
          }

        } catch (error) {
          this.$message.error('获取信息失败')
        }
      },

  
      async submitForm() {
        try {
  
          // 准备提交数据
          const submitData = this.form
          
  

  
          await updateObj(submitData)
          this.$message.success('更新成功')
          this.goBack()
        } catch (error) {
          this.$message.error('更新失败：' + error.message)
        }
      },
      goBack() {
        this.$router.push('/$TABLENAME$/list')
      },
     
  
    }
  }
  </script>
  
  <style scoped>
  .box-card {
    margin: 20px;
  }
    
  .el-form-item {
    margin-bottom: 20px;
  }
  
  </style>
  